<template>
  <div class="certificate-list">
    <h1>所获证书</h1>
    <!-- 表格组件 -->
    <el-table :data="certificates">
      <el-table-column prop="id" label="试卷ID" />
      <el-table-column prop="account" label="账户ID" />
      <el-table-column prop="name" label="账目名称" />
      <el-table-column prop="subject" label="科目" />
      <el-table-column prop="paper_id" label="试卷ID" />
      <el-table-column prop="zhu_fraction" label="主观题总分" />
      <el-table-column prop="ke_fraction" label="客观题总分" />
      <el-table-column prop="fraction" label="总分" />
      <el-table-column prop="certificate_information" label="证书信息" />
      <el-table-column prop="state" label="试卷状态" />
      <el-table-column prop="stfstate" label="证书状态" />
    </el-table>
  </div>
</template>

<script>
import { Table } from 'element-ui'
import { getCertificates } from '@/api/user' // 假设的API方法

export default {
  components: {
    'el-table': Table
  },
  data() {
    return {
      certificates: [],
      currentUserAccountId: sessionStorage.getItem('identity') // 从登录状态或其他方式获取当前账户ID
    }
  },
  created() {
    this.fetchCertificates()
  },
  methods: {
    async fetchCertificates() {
      try {
        const data = {
          account: sessionStorage.getItem('identity')
        }
        const response = await getCertificates(data)
        console.log(response)
        // if (response.ok) { // 确保服务器返回的状态码是 2xx
        //   // this.certificates = response
        // } else {
        //   throw new Error(`Server responded with status ${response.status}`)
        // }
      } catch (error) {
        // console.error('Error fetching certificates:', error)
        // 可以在这里显示一个错误消息给用户
      }
    }
  }
}
</script>

<style scoped>
/* 你的样式 */
</style>
